<script setup lang="ts">
import { computed } from 'vue';
import { useFullscreen } from '@vueuse/core';
import { useAppStore } from '@/store/modules/app';
import { useThemeStore } from '@/store/modules/theme';
import { useRouteStore } from '@/store/modules/route';
import HorizontalMenu from '../global-menu/base-menu.vue';
import GlobalLogo from '../global-logo/index.vue';
import GlobalBreadcrumb from '../global-breadcrumb/index.vue';
import GlobalSearch from '../global-search/index.vue';
import { useMixMenuContext } from '../../context';
import ThemeButton from './components/theme-button.vue';
import UserAvatar from './components/user-avatar.vue';

defineOptions({
  name: 'GlobalHeader'
});

interface Props {
  /** Whether to show the logo */
  showLogo?: App.Global.HeaderProps['showLogo'];
  /** Whether to show the menu toggler */
  showMenuToggler?: App.Global.HeaderProps['showMenuToggler'];
  /** Whether to show the menu */
  showMenu?: App.Global.HeaderProps['showMenu'];
}

defineProps<Props>();

const appStore = useAppStore();
const themeStore = useThemeStore();
const routeStore = useRouteStore();
const { isFullscreen, toggle } = useFullscreen();
const { menus } = useMixMenuContext();

const headerMenus = computed(() => {
  if (themeStore.layout.mode === 'horizontal') {
    return routeStore.menus;
  }

  if (themeStore.layout.mode === 'horizontal-mix') {
    return menus.value;
  }

  return [];
});

// 操作手册点击事件
function mediumClick() {
  window.open('https://cibn.tvjoy.cn/WeChatXHB/files/operatingManual.pdf');
}
</script>

<template>
  <DarkModeContainer class="header h-65px flex-y-center justify-between px-12px shadow-header">
    <div class="ml-16px h-full flex-y-center">
      <GlobalLogo class="h-full" :style="{ width: 122 + 'px' }" />
      <div class="ml-20px mr-20px h-16px w-1px bg-#9E9E9E"></div>
      <RouterLink to="/">
        <NButton class="home-btn" text round :focusable="false">
          <img class="ml-10px" src="@/assets/imgs/icon-header-home.png" alt="" width="15" height="16" />
          <span class="ml-8px mr-10px text-12px font-medium">首页</span>
        </NButton>
      </RouterLink>
    </div>
    <!--
 <HorizontalMenu
      v-if="showMenu"
      mode="horizontal"
      :menus="headerMenus"
      class="px-12px"
    />
-->
    <!--    <div v-else class="h-full flex-y-center flex-1-hidden">-->
    <!--      <MenuToggler v-if="showMenuToggler" :collapsed="appStore.siderCollapse" @click="appStore.toggleSiderCollapse" />-->
    <!--      <GlobalBreadcrumb v-if="!appStore.isMobile" class="ml-12px" />-->
    <!--    </div> -->
    <div class="h-full flex-y-center justify-end">
      <!--      <GlobalSearch />-->
      <!--      <FullScreen v-if="!appStore.isMobile" :full="isFullscreen" @click="toggle" />-->
      <!--      <LangSwitch :lang="appStore.locale" :lang-options="appStore.localeOptions" @change-lang="appStore.changeLocale" />-->
      <!--      <ThemeSchemaSwitch-->
      <!--        :theme-schema="themeStore.themeScheme"-->
      <!--        :is-dark="themeStore.darkMode"-->
      <!--        @switch="themeStore.toggleThemeScheme"-->
      <!--      />-->
      <!--      <ThemeButton />-->
      <RouterLink :to="{ path: '/duplicate-check/create' }">
        <NButton class="header-btn" text round :focusable="false">
          <img class="ml-10px" src="@/assets/duplicate-check/icon-check.png" alt="" width="14" height="14" />
          <span class="ml-8px mr-10px text-12px font-medium">火眼金睛</span>
        </NButton>
      </RouterLink>
      <RouterLink :to="{ path: '/smart-eye/create' }">
        <NButton class="header-btn" text round :focusable="false">
          <img class="ml-10px" src="@/assets/imgs/icon-header-recognition.png" alt="" width="14" height="14" />
          <span class="ml-8px mr-10px text-12px font-medium">慧眼识标</span>
        </NButton>
      </RouterLink>
      <NButton class="header-btn" text round :focusable="false" @click="mediumClick">
        <img class="ml-10px" src="@/assets/imgs/icon-header-manual.png" alt="" width="15" height="16" />
        <span class="ml-8px mr-10px text-12px font-medium">操作手册</span>
      </NButton>
      <RouterLink :to="{ path: '/bid-materials/bid', query: { tab: 2 } }">
        <NButton class="header-btn" text round :focusable="false">
          <img class="ml-10px" src="@/assets/imgs/icon-header-material.png" alt="" width="14" height="14" />
          <span class="ml-8px mr-10px text-12px font-medium">素材管理</span>
        </NButton>
      </RouterLink>
      <UserAvatar />
    </div>
  </DarkModeContainer>
</template>

<style scoped lang="scss">
.header {
  //opacity: 0.7;
  background-image: url('@/assets/home/bg.png');
  background-repeat: no-repeat;
  background-size: cover;
}
.header-btn {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 34px;
  background: rgba(255, 255, 255, 0.6);
  color: #666666;
  border-radius: 17px;
  margin-right: 20px;
}
.header-btn:hover {
  background: rgba(255, 255, 255, 0.6);
  color: #666666;
}
.home-btn {
  width: 96px;
  height: 34px;
  background: linear-gradient(46deg, #e877ae, #7c73f3);
  border-radius: 17px;
  font-weight: 400;
  font-size: 16px;
  color: #ffffff;
  line-height: 34px;
}
.home-btn:hover {
  background: linear-gradient(46deg, #e877ae, #7c73f3);
  color: #ffffff;
}
</style>
